<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item>首页</el-breadcrumb-item>
      <el-breadcrumb-item>{{name}}管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="搜索：">
        <el-input size="small" maxlength="50" show-word-limit v-model="formInline.q" placeholder="输入关键字"></el-input>
      </el-form-item>
      <el-select v-model.number="formInline.grade" clearable placeholder="选择等级">
        <el-option v-for="item in gradeList" :key="item.choice" type="number" :label="item.description" :value="item.choice"></el-option>
      </el-select>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button size="small" type="primary" icon="el-icon-plus" @click="handleAdd()">添加</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column sortable prop="name" label="活动名称" width="150">
      </el-table-column>
      <el-table-column sortable prop="short_intro" label="活动简述" width="250">
      </el-table-column>
      <el-table-column align="center" prop="mode" label="考证模式" width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="grade_list" label="适用等级" width="200">
        <template slot-scope="scope">
          <el-tag v-for="item in scope.row.grade_list" :key="item">{{item}}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" sortable prop="useful" label="状态" width="100">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.useful"
            :active-value="useful.active"
            :inactive-value="useful.inactive"
            @change="handle(scope.row.useful, scope.$index)"
            active-color="#13ce66"
            inactive-color="#ff4949">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column align="center" sortable prop="price" label="价格" width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="end_sign_up_time" label="结束报名时间" width="150">
      </el-table-column>
      <el-table-column align="center" sortable prop="begin_time" label="活动开始时间" width="150">
      </el-table-column>
      <el-table-column align="center" sortable prop="end_time" label="活动结束时间" width="150">
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="200">
        <template slot-scope="scope">
          <el-button size="mini" type="info" @click="toUrl(scope.$index, scope.row)">报名名单</el-button>
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <!-- <el-button size="mini" type="primary" @click="handleOpen(scope.$index)">开放</el-button>
          <el-button size="mini" type="danger" @click="handleClose(scope.$index)">关闭</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <el-pagination
      background
      layout="prev, pager, next, total"
      :current-page="pageparm.currentPage"
      :page-size="pageparm.pageSize"
      :total="pageparm.total"
      @current-change="changePage"
      @prev-click="changePage"
      @next-click="changePage">
    </el-pagination>
    <!-- 添加界面 -->
    <el-dialog :close-on-click-modal="false" :title="`${title}${name}`" :visible.sync="addFormVisible" width="70%" @click="closeDialog">
      <el-form label-width="120px" :model="addForm" :rules="rules" ref="addForm">
        <el-form-item label="活动名称" prop="name">
          <el-input size="small" maxlength="50" show-word-limit v-model="addForm.name" auto-complete="off" placeholder="必填（少于50个字符）"></el-input>
        </el-form-item>
        <el-form-item label="活动简介" prop="short_intro">
          <el-input size="small" maxlength="50" show-word-limit v-model="addForm.short_intro" auto-complete="off" placeholder="必填（少于50个字符）"></el-input>
        </el-form-item>
        <el-form-item label="详细介绍" prop="detail_intro">
          <el-input size="small" type="textarea" maxlength="5000" show-word-limit v-model="addForm.detail_intro" auto-complete="off" placeholder="必填（少于5000个字符）"></el-input>
        </el-form-item>
        <el-form-item label="活动图片列表" prop="img_list">
          <el-upload
            class="upload-demo"
            :action="uploadImageUrl"
            name="file_obj"
            :headers="uploadHeaders"
            :on-remove="handleRemove"
            :on-success="handleSuccess"
            :on-error="handleError"
            :before-upload="handleBeforeUpload"
            :file-list="fileList"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="" prop="img_list">
          <p class="img-url" v-for="item in fileList" :key="item.uid">{{$store.state.imgUrlPix + item.response.data}}</p>
        </el-form-item>
        <el-form-item label="主办方" prop="sponsor">
          <el-input size="small" v-model="addForm.sponsor" auto-complete="off" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="考证模式" prop="mode">
          <el-select v-model="addForm.mode" placeholder="必选" @change="selMode">
            <el-option v-for="item in modeList" :key="item.choice" :label="item.description" :value="item.choice"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="比赛适用等级" prop="grade_list">
          <el-checkbox-group v-model="addForm.grade_list" :disabled="true">
            <el-checkbox v-for="item in gradeList" type="number" :key="item.choice" :label="item.choice">{{item.description}}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="结束报名时间" prop="end_sign_up_time">
          <el-date-picker v-model="addForm.end_sign_up_time" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="必填"></el-date-picker>
        </el-form-item>
        <el-form-item label="开始-结束时间" prop="start_end_time">
          <el-date-picker
            v-model="addForm.start_end_time"
            type="datetimerange"
            value-format="yyyy-MM-dd HH:mm:ss"
            range-separator="至"
            start-placeholder="活动开始日期"
            end-placeholder="活动结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发证单位" prop="certificate_info.issue_unit">
          <el-select v-model="addForm.certificate_info.issue_unit" placeholder="必选">
            <el-option v-for="item in issueList" :key="item.choice" :label="item.description" :value="item.choice"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发证机构盖章" prop="issue_unit_seal_url">
          <el-upload
            name="file_obj"
            :headers="uploadHeaders"
            class="avatar-uploader"
            :action="uploadImagePngUrl"
            :show-file-list="false"
            :on-success="handleSuccessSeal"
            :before-upload="handleBeforeUploadSeal">
            <img class="avatar" v-if="addForm.certificate_info.issue_unit_seal_url" :src="$store.state.imgUrlPix + addForm.certificate_info.issue_unit_seal_url">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
        <el-form-item label="比赛ID" prop="race_id">
          <el-input size="small" v-model="addForm.race_id" auto-complete="off" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="最大人数限制" prop="max_population">
          <el-input size="small" min="1" max="9999" type="number" oninput="value=value.replace(/[^\d]/g,'')" v-model.number="addForm.max_population" auto-complete="off" placeholder="必填"></el-input>
        </el-form-item>
        <el-form-item label="价格" prop="price">
          <el-input size="small" type="number" oninput="value=value.replace(/[^\d]/g,'')" v-model.number="addForm.price" auto-complete="off" placeholder="必填"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitAddForm('addForm')">提交</el-button>
      </div>
    </el-dialog>

    <!-- 编辑页面 -->
    <el-dialog :close-on-click-modal="false" :title="`${title}${name}`" :visible.sync="editFormVisible" width="70%" @click="closeDialog">
      <el-form label-width="120px" :model="editForm" :rules="rules" ref="editForm">
        <el-form-item label="活动名称" prop="name">
          <el-input size="small" maxlength="50" show-word-limit v-model="editForm.name" auto-complete="off" placeholder="必填（少于50个字符）"></el-input>
        </el-form-item>
        <el-form-item label="活动简介" prop="short_intro">
          <el-input size="small" maxlength="50" show-word-limit v-model="editForm.short_intro" auto-complete="off" placeholder="必填（少于50个字符）"></el-input>
        </el-form-item>
        <el-form-item label="详细介绍" prop="detail_intro">
          <el-input size="small" type="textarea" maxlength="5000" show-word-limit v-model="editForm.detail_intro" auto-complete="off" placeholder="必填（少于5000个字符）"></el-input>
        </el-form-item>
        <el-form-item label="图片列表" prop="img_list">
          <el-upload
            class="upload-demo"
            :action="uploadImageUrl"
            name="file_obj"
            :headers="uploadHeaders"
            :on-remove="handleRemove"
            :on-success="handleSuccess"
            :on-error="handleError"
            :file-list="fileListEdit"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过2mb</div>
          </el-upload>
        </el-form-item>
        <el-form-item label="" prop="img_list">
          <p class="img-url" v-for="item in fileListEdit" :key="item.uid">{{$store.state.imgUrlPix + item.response.data}}</p>
        </el-form-item>
        <el-form-item label="主办方" prop="sponsor">
          <el-input size="small" v-model="editForm.sponsor" auto-complete="off" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="发证单位" prop="issue_unit">
          <el-select v-model="editForm.certificate_info.issue_unit" placeholder="必选">
            <el-option v-for="item in issueList" :key="item.choice" :label="item.description" :value="item.choice"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="发证机构盖章" prop="issue_unit_seal_url">
          <el-upload
            name="file_obj"
            :headers="uploadHeaders"
            class="avatar-uploader"
            :action="uploadImagePngUrl"
            :show-file-list="false"
            :on-success="handleSuccessSeal"
            :before-upload="handleBeforeUploadSeal">
            <img class="avatar" v-if="editForm.certificate_info.issue_unit_seal_url" :src="$store.state.imgUrlPix + editForm.certificate_info.issue_unit_seal_url">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </el-form-item>
        <el-form-item label="比赛ID" prop="race_id">
          <el-input size="small" v-model="editForm.race_id" auto-complete="off" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="最大人数限制" prop="max_population">
          <el-input size="small" type="number" min="1" max="9999" oninput="value=value.replace(/[^\d]/g,'')" v-model.number="editForm.max_population" auto-complete="off" placeholder="必填"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitEditForm('editForm')">提交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { activityList, activityListSearch, activityModeList, activitynGradeList,
  activityDetail, uploadImage, activityIssueList,
  activityAdd, activityUpdate, activityOpen, activityClose, uploadImagePngUrl, uploadImageUrl } from '../../api/userMG'
export default {
  data() {
    return {
      loading: false, //是显示加载
      addFormVisible: false, //控制页面显示
      editFormVisible: false, //控制页面显示
      title: '添加',
      name: '考证活动',
      fileList: [],fileListEdit: [],
      gradeList: [],
      modeList: [],
      issueList: [],
      useful: {
        active: 1,
        inactive: 0
      },
      addForm: {
        name: '',
        short_intro: '',
        detail_intro: '',
        img_list: [],
        sponsor: '',
        grade_list: [],
        start_end_time: [],
        end_sign_up_time: '',
        begin_time: '',
        end_time: '',
        mode: '',
        certificate_info: {
          issue_unit: '',
          issue_unit_seal_url: ''
        },
        race_id: '',
        max_population: 1,
        price: 0,
        token: localStorage.getItem('logintoken')
      },
      editForm: {
        main_id: -1,
        name: '',
        short_intro: '',
        detail_intro: '',
        img_list: [],
        sponsor: '',
        certificate_info: {
          issue_unit: '',
          issue_unit_seal_url: ''
        },
        race_id: '',
        max_population: 1,
        token: localStorage.getItem('logintoken')
      },
      uploadHeaders: {
        token: localStorage.getItem('logintoken')
      },
      // rules表单验证
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
        ],
        short_intro: [
          { required: true, message: '请输入活动简介', trigger: 'blur' },
        ],
        detail_intro: [
          { required: true, message: '请输入详细描述', trigger: 'blur' },
        ],
        end_sign_up_time: [
          { type: 'string', required: true, message: '请选择日期', trigger: 'change' }
        ],
        begin_time: [
          { type: 'string', required: true, message: '请选择日期', trigger: 'change' }
        ],
        end_time: [
          { type: 'string', required: true, message: '请选择日期', trigger: 'change' }
        ],
        mode: [
          { required: true, message: '请选择模式', trigger: 'change' }
        ],
        start_end_time: [
          { type: 'array', required: true, message: '请选择活动开始时间和结束时间', trigger: 'change' }
        ],
        img_list: [
          { type: 'array', required: true, message: '请至少上传一张图片', trigger: 'change' }
        ],
        grade_list: [
          { type: 'array', required: true, message: '请至少选择一个等级', trigger: 'change' }
        ],
        max_population: [
          { type: "number", required: true, message: '请填写人数限制', trigger: 'blur' },
        ],
        price: [
          { type: "number", required: true, message: '请填写价格，免费为0', trigger: 'blur' }
        ]
      },
      formInline: {
        location_id: 999999,
        page_index: 1,
        page_size: 15,
        q: '',
        grade: '',
        token: localStorage.getItem('logintoken')
      },
      listData: [], //用户数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 15,
        total: 0
      }
    }
  },
  // 注册组件
  components: {},
  /**
   * 创建完毕
   */
  created() {
    this.getModelist()
    this.getIssuelist()
    this.getGradelist()
    this.getdata(this.formInline)
  },

  /**
   * 里面的方法只有被调用才会执行
   */
  methods: {
    changePage(cur){
      this.pageparm.currentPage = cur;
      this.formInline.page_index = cur;
      this.getdata(this.formInline);
    },
    // 获取列表
    getdata(parameter) {
      this.loading = true
      let target = {}
      Object.assign(target ,parameter);
      if (!target.grade)  delete target.grade
      let rep = activityListSearch(target)
      rep.then(res => {
          console.log(res)
          this.loading = false
          if (res.code === 0) {
            this.listData = res.data.list
            this.pageparm.currentPage = this.formInline.page_index
            this.pageparm.pageSize = this.formInline.page_size
            this.pageparm.total = res.data.total_items
          } else {
            this.$message({
              type: 'info',
              message: res.msg
            })
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('加载失败，请稍后再试！')
        })
    },
    getModelist() {
      let rep = activityModeList()
      rep.then(res => {
        if (res.code === 0) {
          this.modeList = res.data
        } else {
          this.$message({
            type: 'info',
            message: res.msg
          })
        }
      })
      .catch(err => {
        this.loading = false
        this.$message.error('加载失败，请稍后再试！')
      })
    },
    selMode(e) {
      switch (e) {
        case 'question':
          this.addForm.grade_list = this.modeList[0].allow_grade
          break;
        case 'race':
          this.addForm.grade_list = this.modeList[1].allow_grade
          break;
        case 'play_with_pc':
          this.addForm.grade_list = this.modeList[2].allow_grade
          break;
      }
    },
    getIssuelist() {
      let rep = activityIssueList()
      rep.then(res => {
        if (res.code === 0) {
          this.issueList = res.data
        } else {
          this.$message({
            type: 'info',
            message: res.msg
          })
        }
      })
      .catch(err => {
        this.loading = false
        this.$message.error('加载失败，请稍后再试！')
      })
    },
    getGradelist() {
      let rep = activitynGradeList()
      rep.then(res => {
        if (res.code === 0) {
          this.gradeList = res.data
        } else {
          this.$message({
            type: 'info',
            message: res.msg
          })
        }
      })
      .catch(err => {
        this.loading = false
        this.$message.error('加载失败，请稍后再试！')
      })
    },
    handleBeforeUpload(file) {
      const isImage = file.type.includes("image");
      if (!isImage) {
        this.$message.error("上传文件类型必须是图片!");
      }
      return isImage;
    },
    handleBeforeUploadSeal(file) {
      const isImage = file.type.includes("png");
      if (!isImage) {
        this.$message.error("上传文件类型必须是PNG!");
      }
      return isImage;
    },
    handleSuccess(res, file, fL) {
      // console.log('success', res, file, fL);
      if (res.code === 0) {
        if (this.title === '添加') {
          this.fileList = fL
        } else {
          this.fileListEdit = fL
        }
      } else {
        this.$message.error(res.msg)
      }
    },
    handleSuccessSeal(res, file) {
      // console.log('success', res, file);
      if (res.code === 0) {
        if (this.title === '添加') {
          this.addForm.certificate_info.issue_unit_seal_url = res.data
        } else {
          this.editForm.certificate_info.issue_unit_seal_url = res.data
        }
      } else {
        this.$message.error(res.msg)
      }
    },
    handleRemove(file, fL) {
      // console.log(file, fL, this.fileList);
      if (this.title === '添加') {
        this.fileList = fL
      } else {
        this.fileListEdit = fL
      }
    },
    handleError(err, file, fileList) {
      this.$message.error('加载失败，请稍后再试！')
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page_index = parm.currentPage
      this.formInline.page_size = parm.pageSize
      this.getdata(this.formInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.formInline)
    },
    //显示添加界面
    handleAdd() {
      this.addFormVisible = true
      this.title = '添加'
    },
    handleEdit: function(index, row) {
      this.title = '修改'
      this.editForm.main_id = row.main_id
      this.editForm.name = row.name
      this.editForm.short_intro = row.short_intro
      this.editForm.img_list = row.img_list
      this.fileListEdit.length = 0
      for(let i = 0; i < this.editForm.img_list.length; i++){
        this.fileListEdit.push({
          name: '',
          url: `${this.$store.state.imgUrlPix}${this.editForm.img_list[i]}`,
          response: {data: this.editForm.img_list[i]}
        })
      }
      this.editForm.sponsor = row.sponsor
      this.editForm.certificate_info = row.certificate_info
      this.editForm.race_id = row.race_id
      this.editForm.max_population = row.max_population
      activityDetail({main_id: row.main_id})
        .then(res => {
          //console.log(res)
          if (res.code === 0) {
            this.editForm.detail_intro = res.data.detail_intro
          } else {
            this.$message({
              type: 'info',
              message: res.msg
            })
          }
          this.loading = false
          this.editFormVisible = true
        })
        .catch(err => {
          //console.log(err)
          this.loading = false
          this.$message.error('加载失败，请稍后再试！')
        })
    },
    // 编辑、增加页面保存方法
    submitAddForm(addData) {
      if (this.addForm.max_population > 9999 || this.addForm.max_population < 1) {
        this.$message.error('最大人数限制为1~9999！')
        return
      }
      this.addForm.img_list = []
      for (let i = 0; i < this.fileList.length; i++) {
        this.addForm.img_list.push(this.fileList[i].response.data)
      }
      this.$refs[addData].validate(valid => {
        if (valid) {
          this.addForm.begin_time = this.addForm.start_end_time[0]
          this.addForm.end_time = this.addForm.start_end_time[1]
          activityAdd(this.addForm)
            .then(res => {
              this.addFormVisible = false
              this.loading = false
              if (res.code === 0) {
                // 重设添加
                this.fileList = []
                this.addForm = {
                  name: '',
                  short_intro: '',
                  detail_intro: '',
                  img_list: [],
                  sponsor: '',
                  certificate_info: {
                    issue_unit: '',
                    issue_unit_seal_url: ''
                  },
                  grade: [],
                  end_sign_up_time: '',
                  begin_time: '',
                  end_time: '',
                  mode: '',
                  race_id: '',
                  max_population: 1,
                  token: localStorage.getItem('logintoken')
                }
                this.getdata(this.formInline)
                this.$message({
                  type: 'success',
                  message: '提交成功！'
                })
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.addFormVisible = false
              this.loading = false
              this.$message.error('提交失败，请稍后再试！')
            })
        } else {
          return false
        }
      })
    },
    submitEditForm(editData) {
      if (this.editForm.max_population > 9999 || this.editForm.max_population < 1) {
        this.$message.error('最大人数限制为1~9999！')
        return
      }
      let buff = this.editForm.img_list
      this.editForm.img_list = []
      for (let i = 0; i < this.fileListEdit.length; i++) {
        this.editForm.img_list.push(this.fileListEdit[i].response.data)
      }
      this.$refs[editData].validate(valid => {
        if (valid) {
          activityUpdate(this.editForm)
            .then(res => {
              this.editFormVisible = false
              this.loading = false
              if (res.code === 0) {
                this.getdata(this.formInline)
                this.$message({
                  type: 'success',
                  message: '提交成功！'
                })
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.addFormVisible = false
              this.loading = false
              this.$message.error('提交失败，请稍后再试！')
            })
        } else {
          this.editForm.img_list = buff
          return false
        }
      })
    },
    handle(cur, index) {
      if (cur) {
        this.postUseful(true, index)
      } else {
        this.postUseful(false, index)
      }
    },
    handleOpen(index) {
      this.$confirm('确定要开放活动吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
      .then(() => {
        this.postUseful(true, index)
      })
      .catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    },
    handleClose(index) {
      this.$confirm('确定要关闭活动吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.postUseful(false, index)
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
    postUseful(isOpen, index) {
      let rep = isOpen ? activityOpen({main_id: this.listData[index].main_id}) : activityClose({main_id: this.listData[index].main_id})
      let tip = isOpen ? '开放' : '关闭'
      rep.then(res => {
        if (res.code === 0) {
          this.$message({
            type: 'success',
            message: `活动已${tip}!`
          })
          this.getdata(this.formInline)
        } else {
          this.$message({
            type: 'info',
            message: res.msg
          })
        }
      })
      .catch(err => {
        this.loading = false
        this.$message.error('请求失败，请稍后再试！')
      })
    },
    toUrl(index, row) {
      this.$router.push(`/activity/applicationList?activity_id=${row.main_id}`)
    },
    closeDialog() {
      this.addFormVisible = false;
      this.editFormVisible = false;
    }
  }
}
</script>

<style scoped>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
.el-table--border, .el-table--group {
  margin: 20px 0;
}
.img-url {
  border: 1px solid #333;
  border-radius: 10px;
  padding: 0 10px;
}
.avatar {
  width: 200px;
  height: 200px;
  display: block;
}
</style>
